package com.scripts;

import Utilities.Commons;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.testng.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * Created by orlandocampos on 10/14/14.
 */
public class Dropdowns {

    protected static WebDriver  wd;


    @BeforeClass
    public static void setup() {

        wd = new FirefoxDriver();
    }

    @Test
    public static void TestCase() throws Exception{

        wd.get("http://www.mortgagecalculatorplus.com/");

        // FORMA UNO y fea

        WebElement ddM = wd.findElement(By.name("param[start_month]"));

        WebElement ddY = wd.findElement(By.name("param[start_year]"));

        ddM.findElements(By.tagName("option")).get(5).click();

        ddY.findElements(By.tagName("option")).get(5).click();

        Commons.wait(2);

        // FORMA DOS y linda
        //NECESITA import org.openqa.selenium.support.ui.*;

        Select realSelect = new Select(ddY);
        //realSelect.deselectByValue("2000"); // DEBERIA DE FUNCIONAR CON ESTO, PERO POR ALGUNA RAZON NO FUNCIONA.
        realSelect.selectByVisibleText("2000");


        Commons.wait(Commons.TIMEOUT_5_SECONDS);
    }


    @AfterClass
    public static void close(){
        wd.close();
        wd.quit();

    }
}
